var module = module || {};
module.contact = module.contact || {};

module.contact.MessageView = function () {
    return this.constructor.apply(this, arguments);
};

module.contact.MessageView.prototype = {
    constructor: function (options) {
        this.deleteBox = $('.' + options.deleteBox);
        this.checkAllId = $('#' + options.checkAllId);
        this.unCheckAllId = $('#' + options.unCheckAllId);
        this.deleteId = $('#' + options.deleteId);
        this.checkboxId = $('#' + options.checkboxId);
        this.sendId = $('#' + options.sendId);
        $('#' + options.btnShowAddUserForm).on('click', $.proxy(this.btnShowAddUserFormOnClick, this));
        $('#' + options.btnChangeUserName).on('click', $.proxy(this.btnChangeUserNameOnClick, this));
        $('#' + options.btnChangePassword).on('click', $.proxy(this.btnChangePasswordOnClick, this));
        $('#' + options.btnChangeRole).on('click', $.proxy(this.btnChangeRoleOnClick, this));
        console.log(options);
    },

    setCheckAll: function () {
        var that = this.deleteBox;
        this.checkAllId.click(function() {
            that.each(function () {
                this.checked = true;
            });
        });
        return false;
    },

    setUnCheckAll: function () {
        var that = this.deleteBox;
        this.unCheckAllId.click(function() {
            that.each(function () {
                this.checked = false;
            });
        });
        return false;
    },

    setDelete: function() {
        var that = this;
        this.deleteId.click(function() {
            var id = [];
            that.deleteBox.each(function() {
                if (this.checked) {
                    id.push(this.id);
                }
            });
            that.checkboxId.val(id);
            if (id.length != 0) {
                that.sendId.submit();
            }
        });
    }

};


